<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of article
 *
 * @author Administrator
 */
class search extends CI_Controller {

    private $page_size = 10;

    public function __construct() {
        parent::__construct();
        $this->url = $this->uri->segments;
    }

    public function index($id='') {
        $page = isset($_GET['page'])?$_GET['page']:1;//当前页
        $name = htmlspecialchars(trim($this->input->post('searchname')),ENT_QUOTES);
        $this->load->library('a_article');
        $article_obj = new a_article();
        $where['like'] = array(
                            'column' => 'details',
                            'content' => $name,
                            'type' => 'both'
                        );

        $data['article'] = $article_obj->get_search_article_list(CONFIG_ID,0,1,10,$where);

        $arr = array (
            'page' => $page,//当前页
            'page_size' => $this->page_size,     //分页总大小
            'total' => $data['article']['page']['cnt']//总记录数
        );
        $start_page = ($page-1)*$this->page_size;
        $data['pagination'] = new pagination($arr);

        $this->load->view('template_sea',$data);
    }

    private function return_classid($nav_one=array()){
        if(empty($nav_one)){
            return ;
        }else{
            foreach($nav_one as $k=>$v){
                if($v['classlinkname'] == $this->url[2]){
                    return $v['classid'];
                }else{
                    continue;
                }
            }
        }
    }

    public function detail($id) {
        if($id){
            $this->load->library('a_article');
            $article_obj = new a_article();
            $data['article_info'] = $article_obj->get_article($id);
            //print_r($data);
            $this->load->view('article_detail',$data);
        }else{
            redirect('cn/main/nofont');
        }
    }

}
